import request from "@/request";
import type { responseType } from "./interface";

const prefix = "/groupDetailEntity";

// 参数接口
export interface UpdateGroupParams {
  id?: number;
  groupId?: number;
  acc?: string;
  createBy?: string;
  createTime?: Record<string, unknown>;
  updateBy?: string;
  updateTime?: Record<string, unknown>;
  undock?: number;
  state?: number;
  remark?: string;
}

export function updateGroup(params: UpdateGroupParams): Promise<responseType> {
  return request.post(`${prefix}/update`, params);
}

/**
 * 查询-编号
 * @param {string} param
 * @returns
 */
export function selectGroupByID(param: string): Promise<responseType> {
  return request.post(`${prefix}/selectGroupByID/${param}`);
}

/**
 * 列表-分页
 * @param {string} page
 * @param {string} pageSize
 * @returns
 */
export function listPageGroupDetail(
  page: number,
  pageSize: number
): Promise<responseType> {
  return request.post(
    `${prefix}/listPageGroup?page=${page}&pageSize=${pageSize}`
  );
}

// 参数接口
export interface InsertGroupParams {
  id?: number;
  groupId?: number;
  acc?: string;
  createBy?: string;
  createTime?: Record<string, unknown>;
  updateBy?: string;
  updateTime?: Record<string, unknown>;
  undock?: number;
  state?: number;
  remark?: string;
}

/**
 * 保存
 * @param {object} params $!{table.comment}
 * @returns
 */
export function insertGroupDetail(
  params: InsertGroupParams
): Promise<responseType> {
  return request.post(`${prefix}/insert`, params);
}

/**
 * 删除
 * @param {string} param
 * @returns
 */
export function deleteGroupDetail(param: string): Promise<responseType> {
  return request.post(`${prefix}/delete/${param}`);
}
